from window import Window
import pygame; from pygame.locals import *

class WBlock(Window):
    def __init__(self, name, color=(255, 0, 255, 255), special_flags=0, rect=None, z=0):
        Window.__init__(self, name, rect, z)
        self.color = color
        self.special_flags = special_flags
        self.update()
        
    def paint(self, screen, offs_x, offs_y):
        screen.blit(self.surf, (offs_x, offs_y), None, self.special_flags)
        
    def update(self):
        self.surf = pygame.Surface(self.size, SRCALPHA)
        self.surf.fill(self.color)
        
class WImage(Window):
    def __init__(self, name, surf, rect=None, z=0):
        Window.__init__(self, name, rect, z)
        self.surf = surf
    
    @property    
    def surf(self):
        return self._surf
    
    @surf.setter
    def surf(self, value):
        if isinstance(value, pygame.Surface):
            self._surf = value
        else:
            self._surf = pygame.image.load(value).convert_alpha()
        
        self.size = self.surf.get_size()

        
    def paint(self, screen, offs_x, offs_y):
        screen.blit(self.surf, (offs_x, offs_y))